package eerbaar.v2.graphics;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.Point;

import eerbaar.v2.graphics.rect.Rectangle2;

public class Shadow {

    private final Rectangle2 cursor;

    public Shadow(Rectangle2 cursor) {
        this.cursor = cursor;
    }

    public void drawShadow(Graphics2D graphics) {

        Point shadow = new Point(this.cursor.x + 5, this.cursor.y + 5);
        Composite save = graphics.getComposite();

        int type = AlphaComposite.SRC_OVER;
        AlphaComposite alpha = AlphaComposite.getInstance(type, 0.5f);
        graphics.setComposite(alpha);

        graphics.setColor(Color.BLACK);
        graphics.fillRoundRect(shadow.x, shadow.y, this.cursor.width,
                this.cursor.height, 6, 6);

        graphics.setComposite(save);
    }
}
